package com.example.service;

import com.example.entity.Business;
import com.example.entity.Post;
import com.example.mapper.BusinessMapper;
import com.example.mapper.PostMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
帖子业务处理
 */
@Service
public class BusinessService {

    @Resource
    private BusinessMapper businessMapper;

    public void add(Business business) {
        businessMapper.insert(business);
    }

    public void deleteById(Integer id) {
        businessMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Business business) {
        businessMapper.updateById(business);
    }

    public Business selectById(Integer id) {
        return businessMapper.selectById(id);
    }

    public List<Business> selectAll(Business business) {
        return businessMapper.selectAll(business);
    }

    public PageInfo<Business> selectPage(Business business, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Business> businessList = businessMapper.selectAll(business);
        return PageInfo.of(businessList);
    }
}
